package com.hfxt.controller;

import com.alibaba.fastjson.JSON;
import com.hfxt.entity.Provider;
import com.hfxt.entity.User;
import com.hfxt.service.UserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.hfxt.service.ProviderService;

import javax.annotation.Resource;
import java.util.List;

//@Controller
@RestController
@RequestMapping("/test")
public class TestController {
    @Resource
    private ProviderService providerService;
    @Resource
    private UserService userService;

//    @Resource
//    private UserService userService;

    @Resource(name = "user0")
    private User user;

    @GetMapping("/config0")
    public String config0() {
        return user.toString();
    }

    //订单编码验证
    @ResponseBody
    @RequestMapping("/test1")
    public List<Provider> test1() {
        return providerService.queryAllProviders();

    }

    @RequestMapping(value = "/getUserById.html", method = RequestMethod.GET)
    @ApiOperation(notes = "获取单个用户信息", value = "getUserById", protocols = "http", response = User.class, produces = "text/html")
    public String getUser(@ApiParam(value = "主键", name = "id", defaultValue = "1", required = true) @RequestParam Long id) {
        System.out.println("id = " + id);
        return userService.queryUserById(id).toString();
    }
}
